#ifndef _AS_WALL_H_
#define _AS_WALL_H_

#include "ASCommon.h"
//#include <fstream>

NS_AS_BEGIN

class ASWall2D 
{
protected:

	Vector2D    m_vA;
	Vector2D	m_vB;
	Vector2D	m_vN;

	void CalculateNormal()
	{
		Vector2D temp = Vec2DNormalize(m_vB - m_vA);

		m_vN.x = -temp.y;
		m_vN.y = temp.x;
	}

public:

	ASWall2D(){}

	ASWall2D(const Vector2D& A, const Vector2D& B):m_vA(A), m_vB(B)
	{
		CalculateNormal();
	}

	ASWall2D(const Vector2D& A, const Vector2D& B, const Vector2D& N):m_vA(A), m_vB(B), m_vN(N)
	{ }

	//ASWall2D(std::ifstream& in){Read(in);}


	const Vector2D& From()const  {return m_vA;}
	void     SetFrom(const Vector2D& v){m_vA = v; CalculateNormal();}

	const Vector2D& To()const    {return m_vB;}
	void     SetTo(const Vector2D& v){m_vB = v; CalculateNormal();}

	const Vector2D& Normal()const{return m_vN;}
	void     SetNormal(const Vector2D& n){m_vN = n;}

	Vector2D Center()const{return (m_vA+m_vB)/2.0;}

	//std::ostream& Wall2D::Write(std::ostream& os)const
	//{
	//  os << std::endl;
	//  os << From() << ",";
	//  os << To() << ",";
	//  os << Normal();
	//  return os;
	//}

	//void Read(std::ifstream& in)
	// {
	//   double x,y;

	//   in >> x >> y;
	//   SetFrom(Vector2D(x,y));

	//   in >> x >> y;
	//   SetTo(Vector2D(x,y));

	//    in >> x >> y;
	//   SetNormal(Vector2D(x,y));
	// }

};

NS_AS_END

#endif